package UDP;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class Receive {
    public static void main(String[] args) throws IOException {
        DatagramSocket datagramSocket = new DatagramSocket(10086);

        byte[] bytes = new byte[1024];

        DatagramPacket datagramPacket = new DatagramPacket(bytes,bytes.length);
    while (true){
        datagramSocket.receive(datagramPacket);

        System.out.println(datagramPacket.getAddress().getHostAddress());
        System.out.println(datagramPacket.getAddress().getHostName());
        byte[] bytes1 = datagramPacket.getData();
        System.out.println(new String(bytes,0,datagramPacket.getLength()));
        System.out.println(datagramPacket.getLength());
        System.out.println(datagramPacket.getPort());
        System.out.println(datagramPacket.getOffset());

    }

    }
}
